{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**stations**\n",
    "\n",
    "StationReference = Name | MayBeInitial | Platforms\n",
    "\n",
    "|Name | MayBeInitial | Platforms |  \n",
    " |--|--|--|  \n",
    "|a = 鄂州站 | 1 | 2, 1, 3, 6, 4, 5 |  \n",
    "|b = 武九线黄石方向 | 1 | 2, 1 |  \n",
    "|c = 武九客专黄石北方向 | 1 | 1, 2 |  \n",
    "|d = 武九客专葛店南方向 | 1 | 2, 1 |  \n",
    "|e = 武九线何刘方向 | 1 | 1, 2 |  \n",
    "\n",
    "**timetable**  \n",
    " Format: \n",
    " ReportingNumber TrainType MaxSpeedKmph TrainComposition Flags : StationVisit1 StationVisit2 ...  \n",
    "\n",
    " StationVisit format:  \n",
    " StationReferencePlatformNumberFromDurationMinutes  \n",
    "\n",
    " TrainType format:  \n",
    " COMMUTER | FREIGHT | IC | URBAN  \n",
    "\n",
    " TrainComposition format:  \n",
    " vvv...  \n",
    " Each v represents one vehicle. L = locomotive (or control post), C = cargo car, P = passenger car  \n",
    " \n",
    " Flags format:  \n",
    " ff  \n",
    " Each f is one flag. 0 = flag not set, 1 = flag set, X = position not used  \n",
    " Flag positions:  \n",
    " 1 unused (X)  \n",
    " 2 NoBrakingPenalization - if set (1), train does NOT receive penalization when braking at signals  \n",
    "\n",
    "\n",
    "**例子**  \n",
    "|列车编号|类型|最高时速|动拖布置|flag|车站1|车站2|车站3|   \n",
    "|--|--|--|--|--|--|--|--|  \n",
    "|C5627| COMMUTER| 200| LPPL| X1 :| b#1#07:03:00#0| a#3#07:06:00#20 |c#1#07:29:00#0 |  \n",
    "\n"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**车次相关信息**  \n",
    "    车次信息不变 默认commuter  \n",
    "    依照类型设置最高速度 D->200 G->300  \n",
    "    车辆细节 先默认 MTTM 后续修改长编或者重连?  \n",
    "  \n",
    "\n",
    "**停站相关信息**  \n",
    "    仅三点式 进场车站 停站 离场车站  \n",
    "    车站 筛选所有车次始发终到，设置字典更改进场离场  \n",
    "    股道指定 随机指定？  \n",
    "  \n",
    "\n",
    "**表格信息**  \n",
    "从路路通截图导出为Excel进行处理  \n",
    "![格式](表格格式.png)  \n",
    "始发站和终到站更换为进场车站和离场车站  \n",
    "  \n",
    "\n",
    "**车站信息**  \n",
    "![车站](鄂州站.png)  \n",
    "单个车站及进场离场布置  \n",
    "  "
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**库函数部分及常规列车信息部分**  \n",
    "导入库函数，处理表格以及替换字符并导出  \n",
    "使用字典建立常规信息的映射关系  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy\n",
    "import pandas\n",
    "import datetime\n",
    "import random\n",
    "\n",
    "Excelpath = \"鄂州站时刻表.xlsx\"  # Excel时刻表文件路径\n",
    "TextPath=\"trains鄂州.txt\" #游戏时刻表文件路径\n",
    "species = {'K': ['120','LPPP','普速'], 'T': ['140','LPPP','普速'], 'Z': ['160','LPPP','普速'],\n",
    "         'D': ['200','LPPL','动车'], 'C': ['200','LPPL','动车'], 'G': ['300','LPLLPL','高速']}  # 速度和编组映射关系\n",
    "# 车站-编号,股道,股道到达及用时映射关系\n",
    "# 股道到达映射关系.可到达股道,图片左右侧线路key值相同则掉向,\n",
    "station = {'武九线黄石方向': ['b', '123', 0, 3], '武九线何刘方向': ['e', '34', 1, 10], '鄂州站': ['a', '123456', -1, 0], \n",
    "           '武九客专黄石北方向': ['c', '5', 0, 3], '武九客专葛店南方向': ['d', '6', 1, 8], }\n",
    "ThisStation = '鄂州站'\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "# track = {}\n",
    "# 车型关系--待筛选，默认短编\n",
    "marshalling = {}\n",
    "\n",
    "# 始发终到映射关系--待筛选\n",
    "dst = {}\n",
    "\n",
    "# 股道到达,图片左右侧线路,,key值不同则掉向\n",
    "# turnst = {'武九客专武汉方向': 0, '武九客专鄂州方向': 1, '武冈城际黄冈方向': 1}\n",
    "\n",
    "trainDF = pandas.DataFrame(\n",
    "    columns=['列车编号', '类型', '最高时速', '动拖布置', 'flag'])  # 列车整体信息\n",
    "arriveStDF = pandas.DataFrame(columns=['车站名称', '股道', '到达时间', '停站时间'])  # 进场信息\n",
    "stopStDF = pandas.DataFrame(columns=['车站名称', '股道', '到达时间', '停站时间'])  # 停站信息\n",
    "leaveStDF = pandas.DataFrame(columns=['车站名称', '股道', '到达时间', '停站时间'])  # 离场信息\n",
    "\n",
    "# 存储字符串形式的最终结果\n",
    "trainList = []\n",
    "arriveStList = []\n",
    "stopStList = []\n",
    "leaveStList = []\n"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**读取表格及数据处理部分**  \n",
    ">1,读取表格并去除空行  \n",
    ">2,从车次提取速度等级  \n",
    ">3,筛选始发站终到站建立替换字典  \n",
    "  \n",
    "  \n",
    "**车次字符串生成部分**\n",
    ">1,车次信息部分\n",
    ">>车次号,类型,动拖布置及flag保持默认  \n",
    ">>速度等级依照KTZDG等区分映射  \n",
    "\n",
    ">2,停站部分  \n",
    ">>停站2(主要车站) 到时及停站时间来自表格部分  股道随机  \n",
    ">>进场及离场部分 依照游戏先期测试进行平移推算  股道依照上下行安排  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "    车次名称        到时        开时  始发站  终到站\n",
      "0  C5051  09:59:00  10:01:00  咸宁南   阳新\n",
      "1  C5522  20:52:00  21:00:00  大冶北   武汉\n",
      "2  C5604  07:22:00  07:24:00  黄石北   武汉\n",
      "3  D2175  10:09:00  10:16:00  宜昌东  杭州西\n",
      "4  D2225  16:17:00  16:24:00  重庆北   福州\n",
      "{'兰州西', '赣州西', '汉口', '福州', '咸宁南', '郑州东', '武昌', '西安北', '南昌', '杭州西', '宁波', '成都', '厦门北', '武汉东', '宜昌东', '云梦东', '深圳东', '阳新', '景德镇北', '重庆北', '黄石北', '十堰', '梅州西', '上海虹桥', '大冶北', '仙桃', '杭州', '北京西', '温州', '深圳北', '南昌西', '上海南', '温州南', '武汉', '襄阳'}\n"
     ]
    }
   ],
   "source": [
    "# 读取文件\n",
    "sheet = pandas.read_excel(io=Excelpath)\n",
    "\n",
    "sheet = sheet.dropna()\n",
    "sheet=sheet.reset_index(drop=True)\n",
    "\n",
    "print(sheet.head())\n",
    "\n",
    "trainInfo = sheet[\"车次名称\"].to_frame()  # 车辆信息\n",
    "#统计始发终到车站信息\n",
    "ts=pandas.concat([sheet[\"始发站\"].value_counts(),sheet[\"终到站\"].value_counts()])\n",
    "totalStation=ts.index\n",
    "\n",
    "print(set(list(totalStation))) #所有始发站和终到站统计"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'上海南': '武九线黄石方向',\n",
       " '上海虹桥': '武九客专黄石北方向',\n",
       " '云梦东': '武九客专葛店南方向',\n",
       " '仙桃': '武九客专葛店南方向',\n",
       " '兰州西': '武九客专葛店南方向',\n",
       " '北京西': '武九客专葛店南方向',\n",
       " '十堰': '武九线何刘方向',\n",
       " '南昌': '武九线黄石方向',\n",
       " '南昌西': '武九客专黄石北方向',\n",
       " '厦门北': '武九客专黄石北方向',\n",
       " '咸宁南': '武九客专葛店南方向',\n",
       " '大冶北': '武九客专黄石北方向',\n",
       " '宁波': '武九线黄石方向',\n",
       " '宜昌东': '武九客专葛店南方向',\n",
       " '成都': '武九线何刘方向',\n",
       " '景德镇北': '武九客专黄石北方向',\n",
       " '杭州': '武九线黄石方向',\n",
       " '杭州西': '武九客专黄石北方向',\n",
       " '梅州西': '武九客专黄石北方向',\n",
       " '武昌': '武九线何刘方向',\n",
       " '武汉': '武九客专葛店南方向',\n",
       " '武汉东': '武九客专葛店南方向',\n",
       " '汉口': '武九客专葛店南方向',\n",
       " '深圳东': '武九线黄石方向',\n",
       " '深圳北': '武九客专黄石北方向',\n",
       " '温州': '武九线黄石方向',\n",
       " '温州南': '武九客专黄石北方向',\n",
       " '福州': '武九客专黄石北方向',\n",
       " '襄阳': '武九客专葛店南方向',\n",
       " '西安北': '武九客专葛店南方向',\n",
       " '赣州西': '武九客专葛店南方向',\n",
       " '郑州东': '武九客专葛店南方向',\n",
       " '重庆北': '武九客专葛店南方向',\n",
       " '阳新': '武九客专黄石北方向',\n",
       " '黄石北': '武九客专黄石北方向'}"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 手动建立映射关系\n",
    "ArrLeaveSt = {'上海南':'武九线黄石方向',\n",
    " '上海虹桥':'武九客专黄石北方向',\n",
    " '云梦东':'武九客专葛店南方向',\n",
    " '仙桃':'武九客专葛店南方向',\n",
    " '兰州西':'武九客专葛店南方向',\n",
    " '北京西':'武九客专葛店南方向',\n",
    " '十堰':'武九线何刘方向',\n",
    " '南昌':'武九线黄石方向',\n",
    " '南昌西':'武九客专黄石北方向',\n",
    " '厦门北':'武九客专黄石北方向',\n",
    " '咸宁南':'武九客专葛店南方向',\n",
    " '大冶北':'武九客专黄石北方向',\n",
    " '宁波':'武九线黄石方向',\n",
    " '宜昌东':'武九客专葛店南方向',\n",
    " '成都':'武九线何刘方向',\n",
    " '景德镇北':'武九客专黄石北方向',\n",
    " '杭州':'武九线黄石方向',\n",
    " '杭州西':'武九客专黄石北方向',\n",
    " '梅州西':'武九客专黄石北方向',\n",
    " '武昌':'武九线何刘方向',\n",
    " '武汉':'武九客专葛店南方向',\n",
    " '武汉东':'武九客专葛店南方向',\n",
    " '汉口':'武九客专葛店南方向',\n",
    " '深圳东':'武九线黄石方向',\n",
    " '深圳北':'武九客专黄石北方向',\n",
    " '温州':'武九线黄石方向',\n",
    " '温州南':'武九客专黄石北方向',\n",
    " '福州':'武九客专黄石北方向',\n",
    " '襄阳':'武九客专葛店南方向',\n",
    " '西安北':'武九客专葛店南方向',\n",
    " '赣州西':'武九客专葛店南方向',\n",
    " '郑州东':'武九客专葛店南方向',\n",
    " '重庆北':'武九客专葛店南方向',\n",
    " '阳新':'武九客专黄石北方向',\n",
    " '黄石北':'武九客专黄石北方向'}\n",
    "\n",
    "\n",
    "ArrLeaveSt \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>列车编号</th>\n",
       "      <th>类型</th>\n",
       "      <th>最高时速</th>\n",
       "      <th>动拖布置</th>\n",
       "      <th>flag</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>C5051</td>\n",
       "      <td>COMMUTER</td>\n",
       "      <td>200</td>\n",
       "      <td>LPPL</td>\n",
       "      <td>X1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>C5522</td>\n",
       "      <td>COMMUTER</td>\n",
       "      <td>200</td>\n",
       "      <td>LPPL</td>\n",
       "      <td>X1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>C5604</td>\n",
       "      <td>COMMUTER</td>\n",
       "      <td>200</td>\n",
       "      <td>LPPL</td>\n",
       "      <td>X1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>D2175</td>\n",
       "      <td>COMMUTER</td>\n",
       "      <td>200</td>\n",
       "      <td>LPPL</td>\n",
       "      <td>X1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>D2225</td>\n",
       "      <td>COMMUTER</td>\n",
       "      <td>200</td>\n",
       "      <td>LPPL</td>\n",
       "      <td>X1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    列车编号        类型 最高时速  动拖布置 flag\n",
       "0  C5051  COMMUTER  200  LPPL   X1\n",
       "1  C5522  COMMUTER  200  LPPL   X1\n",
       "2  C5604  COMMUTER  200  LPPL   X1\n",
       "3  D2175  COMMUTER  200  LPPL   X1\n",
       "4  D2225  COMMUTER  200  LPPL   X1"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#'列车编号','类型','最高时速','动拖布置','flag' 列车整体信息\n",
    "\n",
    "for index,row in trainInfo.iterrows():\n",
    "    trainNum=row[\"车次名称\"]\n",
    "    maxspeed=(species.get(trainNum[0]))[0]#有字头的列车\n",
    "    if maxspeed==None: #最高速度未找到\n",
    "        maxspeed='120' #普客\n",
    "    \n",
    "    marshalling=(species.get(trainNum[0]))[1]\n",
    "    #trainTC=marshalling.get() #动拖布置\n",
    "    trainDF.loc[index]=[trainNum,\"COMMUTER\",maxspeed,marshalling,\"X1\"]\n",
    "    trainList.append(\"{0} {1} {2} {3} {4} : \".format(trainNum,\"COMMUTER\",maxspeed,marshalling,\"X1\"))\n",
    "trainDF.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "# arriveStList=pandas.DataFrame(columns=['车站名称','股道','到达时间','停站时间'])#进场信息\n",
    "# stopiveStList=pandas.DataFrame(columns=['车站名称','股道','到达时间','停站时间'])#停站信息\n",
    "# leaveStList=pandas.DataFrame(columns=['车站名称','股道','到达时间','停站时间'])#离场信息\n",
    "# stationInfo = sheet[[\"到时\", \"开时\",\"始发站\", \"终到站\"]]  # 时间及停站信息\n",
    "\n",
    "for index, row in sheet.iterrows():\n",
    "    arriveSt = ArrLeaveSt.get(row[\"始发站\"])\n",
    "    leaveSt = ArrLeaveSt.get(row[\"终到站\"])\n",
    "\n",
    "    # 上下行编号区分车辆进场股道为1,2道\n",
    "\n",
    "    if int(row[\"车次名称\"].strip()[-1]) % 2 == 0:\n",
    "        arriveTrack = 2  # 偶数位上行车\n",
    "    else:\n",
    "        arriveTrack = 1  # 奇数下行\n",
    "    # 依照掉向区分离场股道 数值相同即为同一侧需掉向，不同即为不掉向顺向行驶\n",
    "    if (station.get(arriveSt))[2] == (station.get(leaveSt))[2]:\n",
    "        leaveTrack = 3-arriveTrack  # 2->1,1->2\n",
    "    else:\n",
    "        leaveTrack = arriveTrack\n",
    "\n",
    "    # 停站股道,依照映射随机选择\n",
    "    stopTrack = random.choice((station.get(arriveSt)[1]))\n",
    "\n",
    "    at=row[\"到时\"]\n",
    "    lt=row[\"开时\"]\n",
    "    # 统一时间格式\n",
    "    strTime1 = datetime.datetime.strptime(str(at), \"%H:%M:%S\")\n",
    "    strTime2 = datetime.datetime.strptime(str(lt), \"%H:%M:%S\")\n",
    "\n",
    "    stopTime = (strTime2-strTime1).seconds/60  # 分钟为单位的停站时间\n",
    "\n",
    "    arrTime1=strTime1-datetime.timedelta(minutes=(station.get(arriveSt))[3])\n",
    "    #print((str(arrTime1))[10,-1])\n",
    "    arrTime2=str(arrTime1.strftime('%Y-%m-%d %H:%M:%S'))[-8:]\n",
    "    arrTime=datetime.datetime.strptime(arrTime2, \"%H:%M:%S\")\n",
    "\n",
    "    leaveTime1=strTime2+datetime.timedelta(minutes=(station.get(leaveSt))[3])\n",
    "    leaveTime2=str(leaveTime1.strftime('%Y-%m-%d %H:%M:%S'))[-8:]\n",
    "    leaveTime=datetime.datetime.strptime(leaveTime2, \"%H:%M:%S\")\n",
    "\n",
    "    # 进场\n",
    "    arriveStDF.loc[index] = [arriveSt, arriveTrack, arrTime2, 0]\n",
    "    arriveStList.append(\"{0}#{1}#{2}#{3}\".format(\n",
    "        (station.get(arriveSt))[0], arriveTrack, arrTime2, 0))\n",
    "    # 停站\n",
    "    stopStDF.loc[index] = [ThisStation, stopTrack, row[\"到时\"], stopTime]\n",
    "    stopStList.append(\"{0}#{1}#{2}#{3}\".format(\n",
    "        (station.get(ThisStation))[0], stopTrack, row[\"到时\"], int(stopTime)))\n",
    "\n",
    "    # 离场\n",
    "    leaveStDF.loc[index] = [leaveSt, leaveTrack, leaveTime2, 0]\n",
    "    leaveStList.append(\"{0}#{1}#{2}#{3}\".format(\n",
    "        (station.get(leaveSt))[0], leaveTrack, leaveTime2, 0))\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "        车站名称  股道      到达时间  停站时间\n",
      "0  武九客专葛店南方向   1  09:51:00     0\n",
      "1  武九客专黄石北方向   2  20:49:00     0\n",
      "2  武九客专黄石北方向   2  07:19:00     0\n",
      "3  武九客专葛店南方向   1  10:01:00     0\n",
      "4  武九客专葛店南方向   1  16:09:00     0 \n",
      "   车站名称 股道      到达时间  停站时间\n",
      "0  鄂州站  6  09:59:00   2.0\n",
      "1  鄂州站  5  20:52:00   8.0\n",
      "2  鄂州站  5  07:22:00   2.0\n",
      "3  鄂州站  6  10:09:00   7.0\n",
      "4  鄂州站  6  16:17:00   7.0 \n",
      "         车站名称  股道      到达时间  停站时间\n",
      "0  武九客专黄石北方向   1  10:04:00     0\n",
      "1  武九客专葛店南方向   2  21:08:00     0\n",
      "2  武九客专葛店南方向   2  07:32:00     0\n",
      "3  武九客专黄石北方向   1  10:19:00     0\n",
      "4  武九客专黄石北方向   1  16:27:00     0\n"
     ]
    }
   ],
   "source": [
    "print(arriveStDF.head(),'\\n',stopStDF.head(),'\\n',leaveStDF.head())"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**最终车次结果**  \n",
    "合并车辆信息和停站信息  \n",
    "  \n",
    "**导出部分**  \n",
    "导出为train.txt手动附加原文件头部之后替换原时刻表文件  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['C5051 COMMUTER 200 LPPL X1 : d#1#09:51:00#0 a#6#09:59:00#2 c#1#10:04:00#0 ',\n",
       " 'C5522 COMMUTER 200 LPPL X1 : c#2#20:49:00#0 a#5#20:52:00#8 d#2#21:08:00#0 ',\n",
       " 'C5604 COMMUTER 200 LPPL X1 : c#2#07:19:00#0 a#5#07:22:00#2 d#2#07:32:00#0 ',\n",
       " 'D2175 COMMUTER 200 LPPL X1 : d#1#10:01:00#0 a#6#10:09:00#7 c#1#10:19:00#0 ',\n",
       " 'D2225 COMMUTER 200 LPPL X1 : d#1#16:09:00#0 a#6#16:17:00#7 c#1#16:27:00#0 ',\n",
       " 'D2226 COMMUTER 200 LPPL X1 : c#2#14:43:00#0 a#5#14:46:00#2 d#2#14:56:00#0 ',\n",
       " 'D2231 COMMUTER 200 LPPL X1 : d#1#15:39:00#0 a#6#15:47:00#2 c#1#15:52:00#0 ',\n",
       " 'D2232 COMMUTER 200 LPPL X1 : c#2#14:20:00#0 a#5#14:23:00#3 d#2#14:34:00#0 ',\n",
       " 'D2376 COMMUTER 200 LPPL X1 : c#2#15:03:00#0 a#5#15:06:00#2 d#2#15:16:00#0 ',\n",
       " 'D3223 COMMUTER 200 LPPL X1 : d#1#17:48:00#0 a#6#17:56:00#2 c#1#18:01:00#0 ',\n",
       " 'D3226 COMMUTER 200 LPPL X1 : c#2#16:01:00#0 a#5#16:04:00#2 d#2#16:14:00#0 ',\n",
       " 'D3251 COMMUTER 200 LPPL X1 : d#1#17:26:00#0 a#6#17:34:00#2 c#1#17:39:00#0 ',\n",
       " 'D3256 COMMUTER 200 LPPL X1 : c#2#17:19:00#0 a#5#17:22:00#3 d#2#17:33:00#0 ',\n",
       " 'D3265 COMMUTER 200 LPPL X1 : d#1#15:09:00#0 a#6#15:17:00#2 c#1#15:22:00#0 ',\n",
       " 'D3266 COMMUTER 200 LPPL X1 : c#2#13:58:00#0 a#5#14:01:00#2 d#2#14:11:00#0 ',\n",
       " 'D3273 COMMUTER 200 LPPL X1 : d#1#13:27:00#0 a#6#13:35:00#2 c#1#13:40:00#0 ',\n",
       " 'D3274 COMMUTER 200 LPPL X1 : c#2#15:40:00#0 a#5#15:43:00#2 d#2#15:53:00#0 ',\n",
       " 'D3278 COMMUTER 200 LPPL X1 : c#2#21:22:00#0 a#5#21:25:00#2 d#2#21:35:00#0 ',\n",
       " 'D3281 COMMUTER 200 LPPL X1 : d#1#20:16:00#0 a#6#20:24:00#2 c#1#20:29:00#0 ',\n",
       " 'D3282 COMMUTER 200 LPPL X1 : c#2#13:13:00#0 a#5#13:16:00#2 d#2#13:26:00#0 ',\n",
       " 'D3287 COMMUTER 200 LPPL X1 : d#1#11:10:00#0 a#6#11:18:00#2 c#1#11:23:00#0 ',\n",
       " 'D3289 COMMUTER 200 LPPL X1 : d#1#14:14:00#0 a#6#14:22:00#2 c#1#14:27:00#0 ',\n",
       " 'D3290 COMMUTER 200 LPPL X1 : c#2#19:14:00#0 a#5#19:17:00#2 d#2#19:27:00#0 ',\n",
       " 'D3396 COMMUTER 200 LPPL X1 : c#2#21:59:00#0 a#5#22:02:00#3 d#2#22:13:00#0 ',\n",
       " 'D5745 COMMUTER 200 LPPL X1 : d#1#12:38:00#0 a#6#12:46:00#2 c#1#12:51:00#0 ',\n",
       " 'D5746 COMMUTER 200 LPPL X1 : c#2#15:22:00#0 a#5#15:25:00#2 d#2#15:35:00#0 ',\n",
       " 'D5765 COMMUTER 200 LPPL X1 : d#1#13:15:00#0 a#6#13:23:00#2 c#1#13:28:00#0 ',\n",
       " 'D5766 COMMUTER 200 LPPL X1 : c#2#15:51:00#0 a#5#15:54:00#2 d#2#16:04:00#0 ',\n",
       " 'D5769 COMMUTER 200 LPPL X1 : d#1#19:56:00#0 a#6#20:04:00#4 c#1#20:11:00#0 ',\n",
       " 'D5785 COMMUTER 200 LPPL X1 : d#1#18:59:00#0 a#6#19:07:00#7 c#1#19:17:00#0 ',\n",
       " 'D5786  COMMUTER 200 LPPL X1 : c#2#07:52:00#0 a#5#07:55:00#2 d#2#08:05:00#0 ',\n",
       " 'D5852 COMMUTER 200 LPPL X1 : c#2#11:50:00#0 a#5#11:53:00#2 d#2#12:03:00#0 ',\n",
       " 'D5869 COMMUTER 200 LPPL X1 : d#1#09:51:00#0 a#6#09:59:00#2 c#1#10:04:00#0 ',\n",
       " 'D7001 COMMUTER 200 LPPL X1 : d#1#06:21:00#0 a#6#06:29:00#2 c#1#06:34:00#0 ',\n",
       " 'D7007 COMMUTER 200 LPPL X1 : d#1#08:52:00#0 a#6#09:00:00#2 c#1#09:05:00#0 ',\n",
       " 'G1020 COMMUTER 300 LPLLPL X1 : d#2#08:10:00#0 a#6#08:18:00#23 c#2#08:44:00#0 ',\n",
       " 'G1647 COMMUTER 300 LPLLPL X1 : d#1#14:41:00#0 a#6#14:49:00#2 c#1#14:54:00#0 ',\n",
       " 'G1648 COMMUTER 300 LPLLPL X1 : c#2#13:37:00#0 a#5#13:40:00#3 d#2#13:51:00#0 ',\n",
       " 'G1729 COMMUTER 300 LPLLPL X1 : c#1#20:55:00#0 a#5#20:58:00#2 c#2#21:03:00#0 ',\n",
       " 'G1730 COMMUTER 300 LPLLPL X1 : c#2#10:09:00#0 a#5#10:12:00#2 c#1#10:17:00#0 ',\n",
       " 'G1992 COMMUTER 300 LPLLPL X1 : c#2#18:40:00#0 a#5#18:43:00#2 d#2#18:53:00#0 ',\n",
       " 'G2036 COMMUTER 300 LPLLPL X1 : c#2#19:44:00#0 a#5#19:47:00#2 d#2#19:57:00#0 ',\n",
       " 'G2039 COMMUTER 300 LPLLPL X1 : d#1#09:21:00#0 a#6#09:29:00#10 c#1#09:42:00#0 ',\n",
       " 'G2039 COMMUTER 300 LPLLPL X1 : d#1#09:21:00#0 a#6#09:29:00#10 c#1#09:42:00#0 ',\n",
       " 'G2040 COMMUTER 300 LPLLPL X1 : c#2#19:25:00#0 a#5#19:28:00#2 d#2#19:38:00#0 ',\n",
       " 'G2044 COMMUTER 300 LPLLPL X1 : c#2#12:19:00#0 a#5#12:22:00#2 d#2#12:32:00#0 ',\n",
       " 'G2045 COMMUTER 300 LPLLPL X1 : d#1#10:52:00#0 a#6#11:00:00#2 c#1#11:05:00#0 ',\n",
       " 'G2046 COMMUTER 300 LPLLPL X1 : c#2#14:31:00#0 a#5#14:34:00#2 d#2#14:44:00#0 ',\n",
       " 'G2281 COMMUTER 300 LPLLPL X1 : d#1#09:39:00#0 a#6#09:47:00#5 c#1#09:55:00#0 ',\n",
       " 'G2282 COMMUTER 300 LPLLPL X1 : c#2#18:54:00#0 a#5#18:57:00#3 d#2#19:08:00#0 ',\n",
       " 'G2285 COMMUTER 300 LPLLPL X1 : d#1#14:00:00#0 a#6#14:08:00#4 d#2#14:20:00#0 ',\n",
       " 'G2286 COMMUTER 300 LPLLPL X1 : c#2#12:55:00#0 a#5#12:58:00#3 d#2#13:09:00#0 ',\n",
       " 'G2295 COMMUTER 300 LPLLPL X1 : d#1#12:21:00#0 a#6#12:29:00#7 c#1#12:39:00#0 ',\n",
       " 'G2296 COMMUTER 300 LPLLPL X1 : c#2#16:35:00#0 a#5#16:38:00#2 d#2#16:48:00#0 ',\n",
       " 'G2387 COMMUTER 300 LPLLPL X1 : d#1#13:06:00#0 a#6#13:14:00#2 c#1#13:19:00#0 ',\n",
       " 'G2388 COMMUTER 300 LPLLPL X1 : c#2#13:26:00#0 a#5#13:29:00#3 d#2#13:40:00#0 ',\n",
       " 'G2704 COMMUTER 300 LPLLPL X1 : c#2#21:42:00#0 a#5#21:45:00#2 d#2#21:55:00#0 ',\n",
       " 'G2709 COMMUTER 300 LPLLPL X1 : d#1#15:24:00#0 a#6#15:32:00#2 c#1#15:37:00#0 ',\n",
       " 'G2710 COMMUTER 300 LPLLPL X1 : c#2#14:10:00#0 a#5#14:13:00#2 d#2#14:23:00#0 ',\n",
       " 'G2711 COMMUTER 300 LPLLPL X1 : d#1#16:47:00#0 a#6#16:55:00#2 c#1#17:00:00#0 ',\n",
       " 'G2712 COMMUTER 300 LPLLPL X1 : c#2#15:31:00#0 a#5#15:34:00#2 d#2#15:44:00#0 ',\n",
       " 'G639 COMMUTER 300 LPLLPL X1 : d#1#17:05:00#0 a#6#17:13:00#2 c#1#17:18:00#0 ',\n",
       " 'G640 COMMUTER 300 LPLLPL X1 : c#2#09:31:00#0 a#5#09:34:00#3 d#2#09:45:00#0 ',\n",
       " 'G647 COMMUTER 300 LPLLPL X1 : d#1#11:42:00#0 a#6#11:50:00#3 c#1#11:56:00#0 ',\n",
       " 'G867 COMMUTER 300 LPLLPL X1 : d#1#12:10:00#0 a#6#12:18:00#2 c#1#12:23:00#0 ',\n",
       " 'G868 COMMUTER 300 LPLLPL X1 : c#2#16:11:00#0 a#5#16:14:00#10 d#2#16:32:00#0 ',\n",
       " 'K1125 COMMUTER 120 LPPP X1 : e#1#19:00:00#0 a#4#19:10:00#3 b#1#19:16:00#0 ',\n",
       " 'K121 COMMUTER 120 LPPP X1 : e#1#19:12:00#0 a#3#19:22:00#4 b#1#19:29:00#0 ',\n",
       " 'K1255 COMMUTER 120 LPPP X1 : e#1#05:55:00#0 a#4#06:05:00#5 b#1#06:13:00#0 ',\n",
       " 'K1256 COMMUTER 120 LPPP X1 : b#2#09:34:00#0 a#2#09:37:00#3 e#2#09:50:00#0 ',\n",
       " 'K1655 COMMUTER 120 LPPP X1 : e#1#12:09:00#0 a#4#12:19:00#4 b#1#12:26:00#0 ',\n",
       " 'K353 COMMUTER 120 LPPP X1 : e#1#20:24:00#0 a#3#20:34:00#7 b#1#20:44:00#0 ',\n",
       " 'K354 COMMUTER 120 LPPP X1 : b#2#06:51:00#0 a#1#06:54:00#3 e#2#07:07:00#0 ',\n",
       " 'K421 COMMUTER 120 LPPP X1 : e#1#07:39:00#0 a#4#07:49:00#4 b#1#07:56:00#0 ',\n",
       " 'K422 COMMUTER 120 LPPP X1 : b#2#20:43:00#0 a#2#20:46:00#6 e#2#21:02:00#0 ',\n",
       " 'K531 COMMUTER 120 LPPP X1 : e#1#18:27:00#0 a#3#18:37:00#3 b#1#18:43:00#0 ',\n",
       " 'K799 COMMUTER 120 LPPP X1 : e#1#12:28:00#0 a#4#12:38:00#2 b#1#12:43:00#0 ',\n",
       " 'T168 COMMUTER 140 LPPP X1 : b#2#22:15:00#0 a#3#22:18:00#3 d#2#22:29:00#0 ',\n",
       " 'T305 COMMUTER 140 LPPP X1 : e#1#10:29:00#0 a#3#10:39:00#4 b#1#10:46:00#0 ',\n",
       " 'T306 COMMUTER 140 LPPP X1 : b#2#17:40:00#0 a#1#17:43:00#2 e#2#17:55:00#0 ',\n",
       " 'T375 COMMUTER 140 LPPP X1 : d#1#22:23:00#0 a#6#22:31:00#3 b#1#22:37:00#0 ',\n",
       " 'Z25 COMMUTER 160 LPPP X1 : e#1#22:41:00#0 a#4#22:51:00#3 b#1#22:57:00#0 ',\n",
       " 'Z26 COMMUTER 160 LPPP X1 : b#2#05:32:00#0 a#1#05:35:00#3 e#2#05:48:00#0 ',\n",
       " 'Z31 COMMUTER 160 LPPP X1 : e#1#22:56:00#0 a#3#23:06:00#4 b#1#23:13:00#0 ',\n",
       " 'Z32 COMMUTER 160 LPPP X1 : b#2#05:55:00#0 a#2#05:58:00#5 e#2#06:13:00#0 ',\n",
       " 'Z45 COMMUTER 160 LPPP X1 : e#1#23:07:00#0 a#3#23:17:00#4 b#1#23:24:00#0 ',\n",
       " 'Z46 COMMUTER 160 LPPP X1 : b#2#05:43:00#0 a#1#05:46:00#3 e#2#05:59:00#0 ']"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "timeTable =open(file=TextPath,mode=\"a\")\n",
    "finalRes=[]\n",
    "for i in range(0,len(arriveStList)):\n",
    "    tstr=\"{0}{1} {2} {3} \".format(trainList[i],arriveStList[i],stopStList[i],leaveStList[i])\n",
    "    finalRes.append(tstr)\n",
    "    tstr1=tstr+'\\n'\n",
    "    timeTable.writelines(tstr1)\n",
    "\n",
    "timeTable.close()\n",
    "finalRes\n"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.2"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
